// <copyright file="DungeonGenerator.SharedMethods.cs" company="TenneySoftware">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>Robert Tenney</author>
// <email>rob10e@yahoo.com</email>
// <date>April 2009</date>
// <summary>Dungeon level generator.</summary>

// License:

// Product: RPGRoguelikeEngine .Net
// Author: Robert N. Tenney
// Copyright: April 2009

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation version 2
// of the License.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

// This license covers all source code, binaries, and other materials related to this project
// unless specifically stated otherwise.

using System;
using System.Collections.Generic;
using System.Drawing;

using TenneySoftware.Engine;
using TenneySoftware.Engine.Debug;

namespace TenneySoftware.LevelGenerator.DungeonGenerator {
    /// <content>
    /// This file contains the Shared (Defined within ILevelGenerator interface) methods for the generator.
    /// </content>
    public partial class Dungeon : IDebugConsole {
        /// <summary>
        /// Gets an array of integers for the generated level.
        /// </summary>
        /// <returns>An array of integers that represent the results of the generator. 0 =
        /// wall, 1 = floor, 2 = door.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Body", Justification = "Multidimensional preferred")]
        public int[,] LevelArray() {
            int[,] result = new int[this.Level.Width, this.Level.Height];
            for (int y = 0; y < this.Level.Height; y++) {
                for (int x = 0; x < this.Level.Width; x++) {
                    if (this.level.GetLevel(x, y).TypeOfTile == TileType.Wall) {
                        result[x, y] = 0;
                    } else if (this.level.GetLevel(x, y).TypeOfTile == TileType.Floor) {
                        result[x, y] = 1;
                    } else if (this.level.GetLevel(x, y).TypeOfTile == TileType.Door) {
                        result[x, y] = 2;
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Processes the command string sent by the console.
        /// </summary>
        /// <param name="command">String command to process.</param>
        /// <returns>True if command was handled by this module.</returns>
        public bool ConsoleCommand(string command) {
            return false;
        }

        /// <summary>
        /// Sets the size for the level.
        /// </summary>
        /// <param name="size">Size for level.</param>
        public void SetSize(Size size) {
            this.level = new Level(size);
        }

        /// <summary>
        /// Generate will begin the level generation process.
        /// </summary>
        /// <returns>True if level was generated. False if it wasn't.</returns>
        public bool Generate() {
            this.Initialize();
            return this.DungeonGenerate();
        }
    }
}